﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace PingTool
{
    public partial class MyMessageBox : Form
    {
        public int Interval
        {
            get { return this.timer1.Interval; }
            set { this.timer1.Interval = value; }
        }

        public MyMessageBox()
        {
            InitializeComponent();
        }

        public void ShowBox(string message)
        {
            this.timer1.Tick += CloseBox;
            this.label1.Text = message;
            this.Refresh();
            LocationRefresh();
            this.Refresh();
            this.timer1.Start();
            this.Show();
        }

        private void CloseBox(object sender, EventArgs e)
        {
            this.timer1.Stop();
            this.Close();
        }

        private void LocationRefresh()
        {
            this.label1.Anchor = AnchorStyles.None;
            int width = (this.Width - this.label1.Width) / 2;
            int heigth = (this.Height - this.label1.Height) / 2;

            this.label1.Location = new Point(width-7, heigth-25);

        }
    }
}
